package com.xiu.java8.dateapi;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;

public class LocalDateTest {

	public static void main(String[] args) {
		LocalDateTime currTime=LocalDateTime.now();
		System.out.println("当前时间："+currTime);
		LocalDate localDate = currTime.toLocalDate();
		Month month = currTime.getMonth();
		int day = currTime.getDayOfMonth();
		int seconds = currTime.getSecond();
		System.out.println("月: " + month +", 日: " + day +", 秒: " + seconds);
		LocalDateTime date2 = currTime.withDayOfMonth(10).withYear(2012);
	    System.out.println("date2: " + date2);
	        
	    // 12 december 2014
	    LocalDate date3 = LocalDate.of(2014, Month.DECEMBER, 12);
	    System.out.println("date3: " + date3);
	        
	    // 22 小时 15 分钟
	    LocalTime date4 = LocalTime.of(22, 15);
	    LocalTime date41 = LocalTime.of(22, 15,30);
	    System.out.println("date4: " + date4);
	    System.out.println("date41: " + date41);
	        
	    // 解析字符串
	    LocalTime date5 = LocalTime.parse("20:15:30");
	    LocalTime parse = LocalTime.parse("50:52");
	    System.out.println("date5: " + date5);
	    System.out.println("parse: " + parse.getHour());
	}

}
